package com.ruoyi.system.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FloPopCj;
import com.ruoyi.system.service.IFloPopCjService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 流动人口采集Controller
 * 
 * @author ruoyi
 * @date 2024-10-15
 */
@Controller
@RequestMapping("/system/ld_cj")
public class FloPopCjController extends BaseController
{
    private String prefix = "system/ld_cj";

    @Autowired
    private IFloPopCjService floPopCjService;

    @RequiresPermissions("system:ld_cj:view")
    @GetMapping()
    public String ld_cj()
    {
        return prefix + "/ld_cj";
    }

    /**
     * 查询流动人口采集列表
     */
    @RequiresPermissions("system:ld_cj:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FloPopCj floPopCj)
    {
        startPage();
        List<FloPopCj> list = floPopCjService.selectFloPopCjList(floPopCj);
        return getDataTable(list);
    }

    /**
     * 导出流动人口采集列表
     */
    @RequiresPermissions("system:ld_cj:export")
    @Log(title = "流动人口采集", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FloPopCj floPopCj)
    {
        List<FloPopCj> list = floPopCjService.selectFloPopCjList(floPopCj);
        ExcelUtil<FloPopCj> util = new ExcelUtil<FloPopCj>(FloPopCj.class);
        return util.exportExcel(list, "流动人口采集数据");
    }

    /**
     * 新增流动人口采集
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存流动人口采集
     */
    @RequiresPermissions("system:ld_cj:add")
    @Log(title = "流动人口采集", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FloPopCj floPopCj)
    {
        return toAjax(floPopCjService.insertFloPopCj(floPopCj));
    }

    /**
     * 修改流动人口采集
     */
    @RequiresPermissions("system:ld_cj:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        FloPopCj floPopCj = floPopCjService.selectFloPopCjById(id);
        mmap.put("floPopCj", floPopCj);
        return prefix + "/edit";
    }

    /**
     * 修改保存流动人口采集
     */
    @RequiresPermissions("system:ld_cj:edit")
    @Log(title = "流动人口采集", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FloPopCj floPopCj)
    {
        return toAjax(floPopCjService.updateFloPopCj(floPopCj));
    }

    /**
     * 删除流动人口采集
     */
    @RequiresPermissions("system:ld_cj:remove")
    @Log(title = "流动人口采集", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(floPopCjService.deleteFloPopCjByIds(ids));
    }
}
